package site.zhangzhuo.learn_springboot.listener;

import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextClosedEvent;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component;

@Component
public class MyApplicationContextEventListener implements ApplicationListener<ApplicationEvent> {

    @Override
    public void onApplicationEvent(ApplicationEvent event) {
        if (event instanceof ContextRefreshedEvent) {
            //System.out.println("Context Refreshed Event received.");
            // Handle the event
        } else if (event instanceof ContextClosedEvent) {
            //System.out.println("Context Closed Event received.");
            // Handle the event
        }
    }
}
